package com.meixiang.entity.shopping;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

import com.meixiang.R;

import java.util.List;

/**
 * 购物车中的组合套装
 *
 * @author LZRUI
 */
public class CartGroupEntity implements Parcelable {

    private String goodsId; // 组合商品
    private String goodsName; // 组合商品名称
    private String goodsStorePrice; // 商品店铺价格
    private String goodsMarketPrice; // 商品市场价格
    private String goodsImage; // 商品图片
    private List<String> specInfo;

    public CartGroupEntity(String goodsId, String goodsName, String goodsStorePrice, String goodsMarketPrice, String goodsImage, List<String> specInfo) {
        this.goodsId = goodsId;
        this.goodsName = goodsName;
        this.goodsStorePrice = goodsStorePrice;
        this.goodsMarketPrice = goodsMarketPrice;
        this.goodsImage = goodsImage;
        this.specInfo = specInfo;
    }

    public CartGroupEntity() {
    }

    public String getGoodsId() {
        return goodsId == null ? "" : goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName == null ? "" : goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsStorePrice() {
        return goodsStorePrice == null ? "" : goodsStorePrice;
    }

    public void setGoodsStorePrice(String goodsStorePrice) {
        this.goodsStorePrice = goodsStorePrice;
    }

    public String getGoodsMarketPrice() {
        return goodsMarketPrice == null ? "" : goodsMarketPrice;
    }

    public void setGoodsMarketPrice(String goodsMarketPrice) {
        this.goodsMarketPrice = goodsMarketPrice;
    }

    public String getGoodsImage() {
        return goodsImage == null ? "" : goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage;
    }

    public List<String> getSpecInfo() {
        return specInfo;
    }

    public void setSpecInfo(List<String> specInfo) {
        this.specInfo = specInfo;
    }

    /**
     * 拼接specInfo字符串
     *
     * @return string
     */
    public String getSpecInfoString(Context context) {
        String info = "";
        int len = this.specInfo == null ? 0 : this.specInfo.size();
        for (int i = 0; i < len; i++) {
            info += this.specInfo.get(i);
            if (i != len - 1) {
                info += context.getString(R.string.space_str);
            }
        }
        return info;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.goodsId);
        dest.writeString(this.goodsName);
        dest.writeString(this.goodsStorePrice);
        dest.writeString(this.goodsMarketPrice);
        dest.writeString(this.goodsImage);
        dest.writeStringList(this.specInfo);
    }

    protected CartGroupEntity(Parcel in) {
        this.goodsId = in.readString();
        this.goodsName = in.readString();
        this.goodsStorePrice = in.readString();
        this.goodsMarketPrice = in.readString();
        this.goodsImage = in.readString();
        this.specInfo = in.createStringArrayList();
    }

    public static final Parcelable.Creator<CartGroupEntity> CREATOR = new Parcelable.Creator<CartGroupEntity>() {
        @Override
        public CartGroupEntity createFromParcel(Parcel source) {
            return new CartGroupEntity(source);
        }

        @Override
        public CartGroupEntity[] newArray(int size) {
            return new CartGroupEntity[size];
        }
    };
}
